package com.leyou.item.service;

import com.leyou.common.enums.ExceptionEnum;
import com.leyou.common.exception.LyException;
import com.leyou.item.mapper.SpecificationMapper;
import com.leyou.item.pojo.Specification;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName: SpecificationService
 * @Description: 商品模板service
 * @Author: sunt
 * @Date: 2019/11/14 14:59
 * @Version 1.0
 **/
@Service
@Slf4j
public class SpecificationService {

    @Autowired
    private SpecificationMapper specificationMapper;

    /**
     * 根据商品分类ID查询规则模板信息
     * @param id
     * @return
     */
    public Specification querySpecById(Long id) {
        Specification specification = specificationMapper.selectByPrimaryKey(id);
        if(null == specification) {
            throw new LyException(ExceptionEnum.SPEC_DATA_NOT_FOUND);
        }
        return specificationMapper.selectByPrimaryKey(id);
    }
}
